<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<jsp:include page="../header.jsp" />
<script>
$(function(){
	$(document).ready(function() {
		var booklist = '${author.knihaIds}'
		for ( var i in booklist) {
			$j("#knihaIds option:eq(" + i + ")").attr("selected", "selected");
		}
	});
});
</script>
<div id="content">
	<div id="topstory" class="box">
		<h1>
			<fmt:message key="author.title.edit" />
		</h1>
	</div>
	<div class="padding">
		<c:choose>
			<c:when test="${ author != null}">
				<form:form action="submit.do?authorId=${author.id }" commandName="author" method="POST">
					<table border="0" cellspacing="5" cellpadding="0" width="100%" class="formTable tplBorder">
						<tr>
							<td width="15%"></td>
							<td width="35%"></td>
							<td width="15%"></td>
							<td width="35%"></td>
						</tr>
						<tr>
							<td class="label"><fmt:message key="author.name" /></td>
							<td><form:input path="jmeno" /> <form:errors path="jmeno" /></td>
							<td colspan="2" />
						</tr>
						<tr>
							<td class="label"><fmt:message key="author.surname" /></td>
							<td><form:input path="prijmeni" /> <form:errors path="prijmeni" /></td>
							<td colspan="2" />
						</tr>
						<tr>
							<td class="label"><fmt:message key="author.books.name"/></td>
							<td><form:select path="knihaIds" multiple="true" items="${author.knihaList }" itemLabel="nazev" itemValue="id"/></td>
						</tr>
						<tr>
							<td colspan="4"><input type="submit" /></td>
						</tr>
					</table>
				</form:form>
			</c:when>
			<c:otherwise>
				<h3>${error }</h3>
			</c:otherwise>
		</c:choose>
	</div>
	<!-- /padding -->
</div>
<!-- /content -->
<jsp:include page="side-menu.jsp" />
<jsp:include page="../foother.jsp" />
